package com.example.taximeter.mapper;

import com.example.taximeter.bean.Search;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * 查询
 */
@Mapper
public interface SearchMapper {

    //查询查询列表
    @SelectProvider(type = ActivityMapperProvider.class, method = "findSearchAll")
    @Results({
            @Result(property = "factname", column = "fact_name"),
            @Result(property = "carno", column = "car_no"),
            @Result(property = "pricetype", column = "price_type"),
            @Result(property = "companyname", column = "company_name"),
            @Result(property = "jjqtype", column = "jjq_type"),
            @Result(property = "version", column = "version"),
            @Result(property = "sfzx", column = "sfzx")
    })
    List<Search> findSearchAll(Search search);

    //查询最新数量
    @Select("select count(car_no) from search where sfzx = '最新版本' and company_name = #{companyname,jdbcType=VARCHAR}")
    Integer findNewNum(String companyname);

    //查询非最新数量
    @Select("select count(car_no) from search where sfzx = '非最新版本' and company_name = #{companyname,jdbcType=VARCHAR}")
    Integer findNotNewNum(String companyname);

    @Select("select count(car_no) from search where sfzx = '最新版本' ")
    Integer findNewNum2(String companyname);

    //查询非最新数量
    @Select("select count(car_no) from search where sfzx = '非最新版本'")
    Integer findNotNewNum2(String companyname);
}
